<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<style id="style">
div { all: initial; }
div { all: initial; color: red; }
div { color: red; all: initial; }
div { all: initial !important; color: red; }
div { all: initial; color: red !important; }

div { all: inherit; }
div { all: inherit; color: red; }
div { color: red; all: inherit; }
div { all: inherit !important; color: red; }
div { all: inherit; color: red !important; }

div { all: red; all: none; all: 10px; all: auto; all: url(about:blank); }

div { direction: ltr; all: initial; direction: rtl; }
div { direction: ltr; unicode-bidi: bidi-override; all: initial !important; }
div { direction: ltr; all: initial; color: red; }

div { all: initial; font-size: 10px; }

div { all: initial; width: inherit; }

div { all: unset; }
div { all: unset; color: red; }
</style>
<script>
function contains(cssText, property) {
   return cssText.indexOf(property) == 0 || cssText.indexOf(' ' + property) != -1;
}

var cssRules = document.getElementById('style').sheet.cssRules;

test(() => {
    assert_equals(cssRules.length, 18);
    assert_equals(cssRules[0].cssText, "div { all: initial; }");
    assert_not_equals(cssRules[1].cssText, "div { all: initial; color: red; }");
    assert_true(contains(cssRules[1].cssText, "color: red;"));
    assert_true(contains(cssRules[1].cssText, "background: initial;"));
    assert_false(contains(cssRules[1].cssText, "direction: "));
    assert_false(contains(cssRules[1].cssText, "unicode-bidi: "));
    assert_equals(cssRules[2].cssText, "div { all: initial; }");
    assert_equals(cssRules[3].cssText, "div { all: initial !important; }");
    assert_not_equals(cssRules[4].cssText, "div { all: initial; color: red !important; }");
    assert_true(contains(cssRules[4].cssText, "color: red !important;"));
    assert_true(contains(cssRules[4].cssText, "background: initial;"));
    assert_false(contains(cssRules[4].cssText, "direction: "));
    assert_false(contains(cssRules[4].cssText, "unicode-bidi: "));

    assert_equals(cssRules[5].cssText, "div { all: inherit; }");
    assert_not_equals(cssRules[6].cssText, "div { all: inherit; color: red; }");
    assert_true(contains(cssRules[6].cssText, "color: red;"));
    assert_false(contains(cssRules[6].cssText, "direction: "));
    assert_false(contains(cssRules[6].cssText, "unicode-bidi: "));
    assert_equals(cssRules[7].cssText, "div { all: inherit; }");
    assert_equals(cssRules[8].cssText, "div { all: inherit !important; }");
    assert_not_equals(cssRules[9].cssText, "div { all: inherit; color: red !important; }");
    assert_true(contains(cssRules[9].cssText, "color: red !important"));
    assert_true(contains(cssRules[9].cssText, "background: inherit;"));
    assert_false(contains(cssRules[9].cssText, "direction: "));
    assert_false(contains(cssRules[9].cssText, "unicode-bidi: "));

    assert_equals(cssRules[10].cssText, "div { }");

    assert_equals(cssRules[11].cssText, "div { all: initial; direction: rtl; }");

    assert_equals(cssRules[12].cssText, "div { direction: ltr; unicode-bidi: bidi-override; all: initial !important; }");

    assert_false(contains(cssRules[13].cssText, "all: initial;"));
    assert_false(contains(cssRules[13].cssText, "-internal-"));
    assert_true(contains(cssRules[13].cssText, "direction: ltr;"));
    assert_true(contains(cssRules[13].cssText, "color: red;"));

    assert_false(contains(cssRules[14].cssText, "all: initial;"));
    assert_false(contains(cssRules[14].cssText, "-internal-"));
    assert_false(contains(cssRules[14].cssText, "font: initial;"));
    assert_true(contains(cssRules[14].cssText, "font-family: initial;"));

    assert_false(contains(cssRules[15].cssText, "all: initial;"));
    assert_false(contains(cssRules[15].cssText, "-internal-"));
    assert_false(contains(cssRules[14].cssText, "font: initial;"));
    assert_true(contains(cssRules[14].cssText, "marker: initial;"));
    assert_true(contains(cssRules[15].cssText, "width: inherit;"));
    assert_true(contains(cssRules[15].cssText, "min-width: initial;"));
    assert_true(contains(cssRules[15].cssText, "max-width: initial;"));
    assert_false(contains(cssRules[15].cssText, "marker-start: initial;"));
    assert_false(contains(cssRules[15].cssText, "marker-mid: initial;"));
    assert_false(contains(cssRules[15].cssText, "marker-end: initial;"));

    assert_equals(cssRules[16].cssText, "div { all: unset; }");
    assert_false(contains(cssRules[17].cssText, "all: unset;"));
    assert_true(contains(cssRules[17].cssText, "color: red;"));
    assert_true(contains(cssRules[17].cssText, "display: unset;"));
}, 'Test for crbug.com/172051: all shorthand property.');
</script>
